﻿using System.Collections.Generic;

namespace FluentWebRequest
{
    internal class AndConnection : IAndConnection
    {
        private readonly IRequestDataBuilder _requestDataBuilder;
        private readonly IDictionary<string, string> _requestItems;
        private readonly string _url;

        public AndConnection(IRequestDataBuilder requestDataBuilder, string url, IDictionary<string, string> requestItems)
        {
            _requestDataBuilder = requestDataBuilder;
            _url = url;
            _requestItems = requestItems;
        }

        public IRequestDataBuilder ConnectWith
        {
            get
            {
                _requestDataBuilder.ReplaceRequestItems(_requestItems);
                return _requestDataBuilder;
            }
        }

        public IRequestType WithRequestTypeIs(RequestMethodType type)
        {
            return new RequestType(_url, _requestItems);
        }
    }
}